package com.dailyblue.java.standard.design.代理模式.jdk动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JDK1DynamicProxy implements InvocationHandler {

    private Object obj;

    public JDK1DynamicProxy(Object obj) {
        this.obj = obj;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("代理类开始执行了！");
        // 调用被代理对象的方法 灵活
        Object result = method.invoke(obj, args);
        System.out.println("代理类执行完毕！");
        return result;
    }
}
